package com.matt.repository.materials;

import com.matt.domain.materials.MaterielCategory;
import com.matt.foundation.constant.CourseConstant;
import org.apache.commons.lang.StringUtils;
import org.apache.poi.util.StringUtil;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import com.matt.domain.materials.Materiels;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

@Repository
public interface MaterielsRepository extends JpaRepository<Materiels, String>, JpaSpecificationExecutor<Materiels> {

    Page<Materiels> findAllByAidAndCategoryAndDeletedOrderByCreatedDesc(String areaId, MaterielCategory category, boolean deleted, Pageable pageable);

    Page<Materiels> findAllByAidAndCategoryAndConsumableAndDeletedOrderByCreatedDesc(String areaId, MaterielCategory category, boolean consumable, boolean deleted, Pageable pageable);

    Page<Materiels> findAllByAidAndConsumableAndDeletedOrderByCreatedDesc(String areaId, Boolean consumable, boolean deleted, Pageable pageable);

    Page<Materiels> findAllByAidAndDeletedOrderByCreatedDesc(String areaId, boolean deleted, Pageable pageable);

    Materiels findFirstByAidAndCategoryAndNameAndDeleted(String aid, MaterielCategory category, String name, boolean deleted);

    Materiels findFirstByAidAndId(String aid, String id);
}